package graphisme.Checkers;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
// class listening actions on pawn
public class ListenerPion implements MouseListener {

	private CheckersGraphicalInterface plateau;
	private Pion pion;

	public ListenerPion(Pion pion, CheckersGraphicalInterface plateau) {
		this.plateau = plateau;
		this.pion = pion;
	}

	public void mouseClicked(MouseEvent arg0) {

	}

	public void mouseEntered(MouseEvent arg0) {

	}

	public void mouseExited(MouseEvent arg0) {

	}

	public void mousePressed(MouseEvent arg0) {
		// the player can  display the move of his color and abd if it is his turn
		if ((pion.getCouleur().toString().equals("NOIR")
				&& plateau.getAuthorizedColor().equals("noir") && plateau
					.isYourTurn())
				|| (pion.getCouleur().toString().equals("BLANC")
						&& plateau.getAuthorizedColor().equals("blanc") && plateau
							.isYourTurn())) {
			// display pawn move possibility
			plateau.afficherPossibilites(pion);
		}
		// if click on pawn but it is the opponent's turn
		else if(!plateau.isYourTurn() && (pion.getCouleur().toString().equals(plateau.getAuthorizedColor().toUpperCase()))){
			
			JFrame frame = new JFrame("It's nor you turn!!!");
			JOptionPane
			.showMessageDialog(
					
					frame,
					"Stop clicking biatch",
					"Enjoy it !!!!!!!!",
					JOptionPane.PLAIN_MESSAGE);
		}

	}

	public void mouseReleased(MouseEvent arg0) {

	}

}
